<template>
  <div class="popup-content">
    <div class="menu-item" v-for="item in data">
      <span @click="handleItem(item)">{{ item.label }}</span>
      <template v-if="item.child && item.child.length > 0">
        <ul>
          <li class="menu-item" v-for="childItem in item.child" @click="handleItem(childItem)">{{ childItem.label }}</li>
        </ul>
      </template>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  closeFN: {
    type: Function
  }
})
const data = [
  { label: '船舶动态信息' },
  { label: '船舶详细信息' },
  {
    label: '查看轨迹图', child: [
      { label: '10分钟' },
      { label: '1小时' },
      { label: '6小时' }
    ]
  },
  { label: '隐藏轨迹' },
  { label: '人员信息' },
  { label: '进出港信息' },
  { label: '加入关注' }
]
const handleItem = (item) => {
  if (item.child) return
  props.closeFN()
}
</script>

<style lang="scss">
.menu-popup-content {
  background-color: #195E92;

  .menu-item {
    position: relative;
    color: #fff;
    font-size: 12px;
    line-height: 26px;
    padding: 0 12px;
    border-bottom: 1px solid #fff;
    width: 100px;
    text-align: center;
    cursor: pointer;
  }

  ul {
    display: none;
    background-color: #195E92;
    position: absolute;
    top: -1px;
    left: 100%;
    border-left: 1px solid #027DB4;
  }

  .menu-item:hover ul {
    display: block;
  }

  .leaflet-popup-close-button,
  .leaflet-popup-tip-container {
    display: none;
  }

  .leaflet-popup-content-wrapper {
    border-radius: 0;
    background-color: transparent;
    box-shadow: none
  }

  .leaflet-popup-content {
    margin: 0;
  }
}</style>